package com.freedom.common.framework.exception;

import com.freedom.common.core.result.BaseResultCode;
import com.freedom.common.core.enums.ResultCodeEnum;
import lombok.Data;
import lombok.EqualsAndHashCode;

@Data
@EqualsAndHashCode(callSuper = true)
public class ServiceException extends RuntimeException {

    public static final String DEFAULT_MESSAGE = "网络错误，请稍后重试！";

    /**
     * 异常消息
     */
    private String message = DEFAULT_MESSAGE;

    /**
     * 错误码
     */
    public BaseResultCode resultCode;

    public ServiceException(BaseResultCode errorCode) {
        super(errorCode.getMsg());
        this.resultCode = errorCode;
    }

    public ServiceException(String message){
        this.resultCode = ResultCodeEnum.ERROR;
        this.message = message;
    }

    public ServiceException(String message, Throwable cause){
        super(message, cause);
    }

    public ServiceException(Throwable cause){
        super(cause);
    }
}
